package com.itheima.day06;
/*
案例6:
遍历二维数组
 */

public class TestClassCase05 {

    public static void main(String[] args) {

        int[][] num={{10,12,20},{14,15,9},{10,13,8},{10,12,15}};

        //二维数组求和

        int[] sum=new int[num.length];

        for (int i = 0; i < num.length; i++) {
            for (int j = 0; j < num[i].length; j++) {
                System.out.print(num[i][j]+" ");
                if(i==1){
                    sum[i]+=num[i][j];
                }else if(i==2){
                    sum[i]+=num[i][j];
                }else if(i==3){
                    sum[i]+=num[i][j];
                }else{
                    sum[i]+=num[i][j];
                }


            }
            System.out.println();
        }


        for (int i = 0; i < sum.length; i++) {
            System.out.println("第"+(i+1)+"季度的总收入:"+sum[i]+"万元");
        }

        int sumNum=0;
        for (int i = 0; i < sum.length; i++) {
            sumNum+=sum[i];
        }
        System.out.println("季度总收入为:"+sumNum+"万元");
    }
}
